﻿@model RTracker.Models.User.GUser

@{
    ViewBag.ModuleName = "User";
    ViewBag.bPagingEnabled = true;
    ViewBag.bSearchEnabled = true;
    ViewBag.bNewDeleteEnabled = true;
    ViewBag.bCopyPasteEnabled = false;
    ViewBag.bLockingEnabled = true;
    ViewBag.bCanCreate = true;
    ViewBag.bCanDelete = true;


}


@* /** Grid List section Starts **/
    "gd-grid-div-width-cls" : Class Contains the width of Grid Section.
*@
<div class="gd-grid-div-width-cls" id="main-list-id">
    @* /** Event Controller Call **/
        "gd-control-div-cls" : Class Contains the design for Control Events.
    *@

    <div id="" class="gd-control-div-cls gd-grid-div-width-cls">
        @*loading partial view _DynamicGrid this loads grid*@
        @Html.Partial("../GridView/_DynamicGrid", Model.Paging)
    </div>
    @* /** Event Controller Ends **/ *@

    @* /** Grid View Starts **/
        "gd-grid-div-width-cls" : Class Contains the width of Grid Section.
        "gd-grid-list-design-cls" : Class Contains the design for grid list.
    *@
    <div class="div-gb-list-cls gd-grid-div-width-cls grid-top-padding-cls gd-grid-list-design-cls">

        <table id="tbl-gd-main" class="gd-grid-div-width-cls" style="table-layout: fixed">
            @* Header Section Starts
                "tr-gd-header-cls" : Class contains the header section properties.
            *@
            <tr class="tr-gd-header-cls">
                @* CheckBox *@
                <th class="grid-header-cls grid-gb-chk-hdl-cls gb-align-center-cls" id="grid-header-id">
                    <input class="chk-gd-header-cls" type="checkbox" />
                </th>

                @* Hardlock Head *@
                @if (ViewBag.bLockingEnabled == true)
                {
                    <th class="grid-header-cls grid-gb-chk-hdl-cls">

                    </th>
                }

                @*displaying header name for the OrganizationName*@

                <th id="first_name" @if (@ViewBag.SortOn == "first_name") { if (@ViewBag.SortType == "asc") { <text> class="headerSortUp grid-header-cls grid-gb-data-col-cls" </text>         } else { <text> class="headerSortDown grid-header-cls grid-gb-data-col-cls" </text>         } } else { <text> class="grid-sort-cls grid-header-cls grid-gb-data-col-cls" </text>         }>
                    @Html.DisplayNameFor(model => model.User.FirstName)
                </th>


                @*displaying header description for the City*@
                <th id="email_address"
                    @if (@ViewBag.SortOn == "email_address") { if (@ViewBag.SortType == "asc") { <text> class="headerSortUp grid-header-cls grid-gb-data-col-cls" </text>     } else { <text> class="headerSortDown grid-header-cls grid-gb-data-col-cls" </text>     } } else { <text> class="grid-sort-cls grid-header-cls grid-gb-data-col-cls" </text>     }>
                    @Html.DisplayNameFor(model => model.User.EmailAddress)
                </th>

                @*display header for the TeamColor*@
                <th id="title" @if (@ViewBag.SortOn == "title") { if (@ViewBag.SortType == "asc") { <text> class="headerSortUp grid-header-cls grid-gb-data-col-cls" </text>      } else { <text> class="headerSortDown grid-header-cls grid-gb-data-col-cls" </text>      } } else { <text> class="grid-sort-cls grid-header-cls grid-gb-data-col-cls" </text>       }>
                    @Html.DisplayNameFor(model => model.User.Title)
                </th>
            </tr>

            @*this loop checks each and every item of model and displays their name,description and TeamColor accordingly*@
            @if (Model.LstUser.Count > 0)
            {

                foreach (var item in Model.LstUser)
                {
                    <tr id="tr-row-@item.UserId" class="tr-gd-row-cls gd-row-color-default-cls mouse-over-color-cls">
                        @* Checkbox Section for rows to select the Row *@
                        <td class="gb-align-center-cls td-gd-chk-cls">
                            <input class="chk-gd-row-cls" type="checkbox" />
                        </td>

                        @* HardLock and SoftLock Spacing for Records *@
                        @if (ViewBag.bLockingEnabled == true)
                        {
                            <td class="gd-td-default-lock-cls">

                                @* Check for SoftLock *@
                                @if (item.IsSoftLocked == true)
                                {
                                    @* If SoftLock is applied by user that is Logged in, then This Condition will satisfy *@
                                    if (item.SoftLockedBy == ViewBag.CurrentUser)
                                    {
                                        <span class="gd-softlock-by-owner-cls"></span>
                                    }
                                    @* If SoftLock is applied by another user then the Logged in User, then This Condition will satisfy *@
                                    else
                                    {
                                        <span class="gd-softlock-img-cls"></span>
                                    }

                                }
                                @* Check for HardLock *@
                                else if (item.IsHardLocked == true)
                                {
                                    @* If HardLock is applied by user that is Logged in, then This Condition will satisfy *@
                                    if (item.HardLockedBy == ViewBag.CurrentUser)
                                    {
                                        <span class="gd-hardlock-by-owner-cls"></span>
                                    }
                                    @* If HardLock is applied by another user then the Logged in User, then This Condition will satisfy *@
                                    else
                                    {
                                        <span class="gd-hardlock-img-cls"></span>
                                    }
                                }
                                @* Default Lock Class  *@
                                else
                                {
                                    <span class="gd-default-lock-cls"></span>
                                }
                            </td>
                        }

                        @*displaying name for the businesunitname*@
                        <td class="  grid-gb-data-col-cls">
                            @Html.DisplayFor(modelItem => item.FirstName)
                        </td>



                        @*displaying name for the BusinessUnitDescription*@
                        <td class="grid-gb-data-col-cls">
                            @Html.DisplayFor(modelItem => item.EmailAddress)
                        </td>



                        @*displaying name for the CreateTimestamp*@
                        <td class="grid-gb-data-col-cls">
                            @Html.DisplayFor(modelItem => item.Title)
                        </td>
                    </tr>
                    <tr class="gb-hidden-cls detail-section" id="tr-row-detail-@item.UserId" style="background-color:#D8E1E7">
                        <td id="td-row-detail-@item.UserId" class="detail-section-td-cls" colspan="5"></td>
                    </tr>
                }
            }

        </table>
    </div>
    @* /** Grid View Ends **/*@
</div>
@* /** Grid List section Ends **/ *@


<script>

    $(".gd-softlock-img-cls").each(function () {

        $(this).parent().parent().children().children(".chk-gd-row-cls").addClass("gd-disabled-cls").attr("disabled", true);

    });


    $(".gd-hardlock-img-cls").each(function () {
        $(this).parent().parent().children().children(".chk-gd-row-cls").addClass("gd-disabled-cls").attr("disabled", true);

    });
    var nCount = 0;
    $(".chk-gd-row-cls").each(function () {

        if (!$(this).hasClass("gd-disabled-cls")) {

            nCount = nCount + 1;
        }
    });
    if (nCount == 0) {
        $(".chk-gd-header-cls").addClass("gd-disabled-cls");
        $(".chk-gd-header-cls").attr("disabled", true);
    }

</script>